1 Podsumowanie analizy

2 Wstęp

2.1 Ładowanie bibliotek

library(knitr)
library(tidyverse)
library(plotly)
library(dplyr)
library(ggplot2)
library(data.table)
library(R.utils)
library(imager)
library(scales)
library(stringr)
library(gganimate)
library(caret)
library(ggcorrplot)
library(forecast)

2.2 Ładowanie danych

colors_df <- fread("rebrickable/colors.csv.gz")
elements_df <- fread("rebrickable/elements.csv.gz")
inventories_df <- fread("rebrickable/inventories.csv.gz")
inventory_minifigs_df <- fread("rebrickable/inventory_minifigs.csv.gz")
inventory_parts_df <- fread("rebrickable/inventory_parts.csv.gz")
inventory_sets_df <- fread("rebrickable/inventory_sets.csv.gz")
minifigs_df <- fread("rebrickable/minifigs.csv.gz")
part_categories_df <- fread("rebrickable/part_categories.csv.gz")
part_relationships_df <- fread("rebrickable/part_relationships.csv.gz")
parts_df <- fread("rebrickable/parts.csv.gz")
sets_df <- fread("rebrickable/sets.csv.gz")
themes_df <- fread("rebrickable/themes.csv.gz")

2.3 Podsumowanie zbioru danych

Zbiór danych Rebrickable składa się z 12 tabel, które przedstawione są na schemacie poniżej. Schemat został pobrany ze strony Rebrickable i brakuje w nim części atrybów w tabelach. Dokładny opis, podstawowe statystyki oraz próbki danych z poszczególnych tabel znajdują się poniżej.

2.3.1 Tabela colors

Tabela zawierająca oficjalne kolory klocków.

  • id - id koloru
  • name - nazwa koloru
  • rgb - kod rgb koloru
  • is_trans - czy kolor jest transparentny
id name rgb is_trans
Min. : -1.0 Length:263 Length:263 Length:263
1st Qu.: 83.0 Class :character Class :character Class :character
Median :1005.0 Mode :character Mode :character Mode :character
Mean : 651.4 NA NA NA
3rd Qu.:1070.5 NA NA NA
Max. :9999.0 NA NA NA
id name rgb is_trans
-1 [Unknown] 0033B2 f
0 Black 05131D f
1 Blue 0055BF f
2 Green 237841 f
3 Dark Turquoise 008F9B f
4 Red C91A09 f

2.3.2 Tabela elements

Tabela zawierająca pojedyncze klocki Lego.

  • element_id - id elementu
  • part_num - numer części
  • color_id - id koloru
  • design_id - id modelu
element_id part_num color_id design_id
Min. : 9327 Length:84138 Min. : -1.0 Min. : 1001
1st Qu.: 4259774 Class :character 1st Qu.: 8.0 1st Qu.: 18454
Median : 6057754 Mode :character Median : 28.0 Median : 41748
Mean : 5222065 NA Mean : 539.7 Mean : 45570
3rd Qu.: 6262024 NA 3rd Qu.: 135.0 3rd Qu.: 75475
Max. :61532443 NA Max. :9999.0 Max. :107520
NA NA NA NA’s :23682
element_id part_num color_id design_id
6443403 2277c01pr0009 1 2277
6300211 67906c01 14 67908
4566309 2564 0 2564
4275423 53657 1004 53657
6194308 92926 71 28967
6229123 26561 4 26561

2.3.3 Tabela inventories

Tabela nadrzędna wiążąca części i figurki z zestawami Lego.

  • id - id zapasu
  • version - wersja zapasu
  • set_num - numer zestawu
id version set_num
Min. : 1 Min. : 1.000 Length:37265
1st Qu.: 14424 1st Qu.: 1.000 Class :character
Median : 54379 Median : 1.000 Mode :character
Mean : 61104 Mean : 1.091 NA
3rd Qu.: 88842 3rd Qu.: 1.000 NA
Max. :194312 Max. :16.000 NA
id version set_num
1 1 7922-1
3 1 3931-1
4 1 6942-1
15 1 5158-1
16 1 903-1
17 1 850950-1

2.3.4 Tabela inventory minifigs

Tabela zawierająca zapasy figurek Lego.

  • inventory_id - id zapasu
  • fig_num - numer figurki
  • quantity - liczba figurek
inventory_id fig_num quantity
Min. : 3 Length:20858 Min. : 1.000
1st Qu.: 7869 Class :character 1st Qu.: 1.000
Median : 15681 Mode :character Median : 1.000
Mean : 43010 NA Mean : 1.062
3rd Qu.: 66834 NA 3rd Qu.: 1.000
Max. :194312 NA Max. :100.000
inventory_id fig_num quantity
3 fig-001549 1
4 fig-000764 1
19 fig-000555 1
25 fig-000574 1
26 fig-000842 1
26 fig-008641 1

2.3.5 Tabela inventory parts

Tabela zawierająca zapasy części Lego.

  • inventory_id - id zapasu
  • part_num - numer części
  • color_id - id koloru
  • quantity - liczba częsci
  • is_spare - czy część jest zapasowa
  • img_url - adres url obrazka
inventory_id part_num color_id quantity is_spare img_url
Min. : 1 Length:1180987 Min. : -1.0 Min. : 1.00 Length:1180987 Length:1180987
1st Qu.: 9404 Class :character 1st Qu.: 4.0 1st Qu.: 1.00 Class :character Class :character
Median : 22838 Mode :character Median : 15.0 Median : 2.00 Mode :character Mode :character
Mean : 50849 NA Mean : 131.8 Mean : 3.37 NA NA
3rd Qu.: 87088 NA 3rd Qu.: 71.0 3rd Qu.: 4.00 NA NA
Max. :194312 NA Max. :9999.0 Max. :3064.00 NA NA
inventory_id part_num color_id quantity is_spare img_url
1 48379c01 72 1 f https://cdn.rebrickable.com/media/parts/photos/1/48379c01-1-e7daa845-2671-4737-8642-3b1574308155.jpg
1 48395 7 1 f https://cdn.rebrickable.com/media/parts/photos/7/48395-7-b9152acf-2fa5-4836-a04d-5b7fd39c2406.jpg
1 stickerupn0077 9999 1 f
1 upn0342 0 1 f
1 upn0350 25 1 f
3 2343 47 1 f https://cdn.rebrickable.com/media/parts/elements/3000240.jpg

2.3.6 Tabela inventory sets

Tabela zawierająca zapasy zestawów Lego.

  • inventory_id - id zapasu
  • set_num - numer zestawu
  • quantity - liczba zestawów
inventory_id set_num quantity
Min. : 35 Length:4358 Min. : 1.000
1st Qu.: 8076 Class :character 1st Qu.: 1.000
Median : 16423 Mode :character Median : 1.000
Mean : 52519 NA Mean : 1.813
3rd Qu.: 98685 NA 3rd Qu.: 1.000
Max. :191576 NA Max. :60.000
inventory_id set_num quantity
35 75911-1 1
35 75912-1 1
39 75048-1 1
39 75053-1 1
50 4515-1 1
50 4520-1 2

2.3.7 Tabela minifigs

Tabela zawierająca figurki Lego.

  • fig_num - numer figurki
  • name - nazwa figurki
  • num_parts - numer części
  • img_url - adres url obrazka
fig_num name num_parts img_url
Length:13764 Length:13764 Min. : 0.000 Length:13764
Class :character Class :character 1st Qu.: 4.000 Class :character
Mode :character Mode :character Median : 4.000 Mode :character
NA NA Mean : 5.296 NA
NA NA 3rd Qu.: 5.000 NA
NA NA Max. :156.000 NA
fig_num name num_parts img_url
fig-000001 Toy Store Employee 4 https://cdn.rebrickable.com/media/sets/fig-000001.jpg
fig-000002 Customer Kid 4 https://cdn.rebrickable.com/media/sets/fig-000002.jpg
fig-000003 Assassin Droid, White 8 https://cdn.rebrickable.com/media/sets/fig-000003.jpg
fig-000004 Man, White Torso, Black Legs, Brown Hair 4 https://cdn.rebrickable.com/media/sets/fig-000004.jpg
fig-000005 Captain America with Short Legs 3 https://cdn.rebrickable.com/media/sets/fig-000005.jpg
fig-000006 Lloyd Avatar 5 https://cdn.rebrickable.com/media/sets/fig-000006.jpg

2.3.8 Tabela part categories

Tabela zawierająca kategorie części Lego.

  • id - id kategorii
  • name - nazwa kategorii
id name
Min. : 1.00 Length:66
1st Qu.:19.25 Class :character
Median :35.50 Mode :character
Mean :35.36 NA
3rd Qu.:51.75 NA
Max. :68.00 NA
id name
1 Baseplates
3 Bricks Sloped
4 Duplo, Quatro and Primo
5 Bricks Special
6 Bricks Wedged
7 Containers

2.3.9 Tabela part relationships

Tabela zawierająca relacvje między częściami.

  • rel_type - typ relacji
  • child_part_num - numer części potomka
  • parent_part-num - numer częsci rodzica
rel_type child_part_num parent_part_num
Length:29977 Length:29977 Length:29977
Class :character Class :character Class :character
Mode :character Mode :character Mode :character
rel_type child_part_num parent_part_num
P 3626cpr3662 3626c
P 87079pr9974 87079
P 3960pr9971 3960
R 98653pr0003 98086pr0003
R 98653pr0003 98088pat0003
R 98653pr0003 98089pat0003

2.3.10 Tabela parts

Tabela zawierająca części Lego.

  • part_num - numer części
  • name - nazwa częsci
  • part_cat_id - id kategorii
  • part_material - materiał, z którego wykonano część
part_num name part_cat_id part_material
Length:52615 Length:52615 Min. : 1.00 Length:52615
Class :character Class :character 1st Qu.:17.00 Class :character
Mode :character Mode :character Median :41.00 Mode :character
NA NA Mean :38.91 NA
NA NA 3rd Qu.:60.00 NA
NA NA Max. :68.00 NA
part_num name part_cat_id part_material
003381 Sticker Sheet for Set 663-1 58 Plastic
003383 Sticker Sheet for Sets 618-1, 628-2 58 Plastic
003402 Sticker Sheet for Sets 310-3, 311-1, 312-3 58 Plastic
003429 Sticker Sheet for Set 1550-1 58 Plastic
003432 Sticker Sheet for Sets 357-1, 355-1, 940-1 58 Plastic
003434 Sticker Sheet for Set 575-2, 653-1, 460-1 58 Plastic

2.3.11 Tabela sets

Tabela zawierająca zestawy dostępne w sklepach.

  • set_num - numer zestawu
  • name - nazwa zestawu
  • year - rok wydania zestawu
  • theme_id - id motywu
  • num_parts - liczba części w zestawie
  • img_url - adres url obrazka
set_num name year theme_id num_parts img_url
Length:21880 Length:21880 Min. :1949 Min. : 1 Min. : 0.0 Length:21880
Class :character Class :character 1st Qu.:2001 1st Qu.:273 1st Qu.: 3.0 Class :character
Mode :character Mode :character Median :2012 Median :497 Median : 31.0 Mode :character
NA NA Mean :2008 Mean :442 Mean : 161.4 NA
NA NA 3rd Qu.:2018 3rd Qu.:608 3rd Qu.: 139.0 NA
NA NA Max. :2024 Max. :752 Max. :11695.0 NA
set_num name year theme_id num_parts img_url
001-1 Gears 1965 1 43 https://cdn.rebrickable.com/media/sets/001-1.jpg
0011-2 Town Mini-Figures 1979 67 12 https://cdn.rebrickable.com/media/sets/0011-2.jpg
0011-3 Castle 2 for 1 Bonus Offer 1987 199 0 https://cdn.rebrickable.com/media/sets/0011-3.jpg
0012-1 Space Mini-Figures 1979 143 12 https://cdn.rebrickable.com/media/sets/0012-1.jpg
0013-1 Space Mini-Figures 1979 143 12 https://cdn.rebrickable.com/media/sets/0013-1.jpg
0014-1 Space Mini-Figures 1979 143 2 https://cdn.rebrickable.com/media/sets/0014-1.jpg

2.3.12 Tabela themes

Tabela zawierająca oryginalne kategorie zestawów jak i współprace.

  • id - id motywu
  • name - nazwa motywu
  • parent_id - id rodzica
id name parent_id
Min. : 1.0 Length:468 Min. : 1.0
1st Qu.:250.5 Class :character 1st Qu.:186.0
Median :466.0 Mode :character Median :411.0
Mean :433.5 NA Mean :360.6
3rd Qu.:625.2 NA 3rd Qu.:512.5
Max. :752.0 NA Max. :697.0
NA NA NA’s :145
id name parent_id
1 Technic NA
3 Competition 1
4 Expert Builder 1
16 RoboRiders 1
17 Speed Slammers 1
18 Star Wars 1

3 Analiza

3.1 Analizy ogólne

3.1.1 Analiza kolorów

3.1.2 Analiza figurek

fig_num name img_url count
fig-002229 Skeleton, Standard Face, Ball Joint Arms (3626b Head) 43
fig-002330 Battle Droid, One Bent Arm, One Straight Arm 40
fig-000020 Classic Spaceman, Red with Airtanks (3842a Helmet) 39
fig-001127 Classic Spaceman, White with Airtanks (3842a Helmet) 37
fig-002118 Steve 27
fig-000225 Policeman, Black Suit with Pocket and Badge, White Hat (3626a Head) 24
fig-000341 Classic Spaceman, Yellow with Airtanks (3842b Helmet) 21
fig-000359 Johnny Thunder (Desert) 21
fig-003612 Battle Droid, Two Bent Arms 21
fig-000124 Chewbacca, Reddish Brown 20

3.1.3 Analiza części

part_num name img_url color_id count
2780 Technic Pin with Friction Ridges Lengthwise and Center Slots 0 4769
6141 Plate Round 1 x 1 with Solid Stud 36 2922
3023 Plate 1 x 2 0 2630
6141 Plate Round 1 x 1 with Solid Stud 0 2371
3673 Technic Pin without Friction Ridges Lengthwise 71 2312
43093 Technic Axle Pin with Friction Ridges Lengthwise 1 2264
3023 Plate 1 x 2 15 2256
4274 Technic Pin 1/2 71 2237
3022 Plate 2 x 2 0 2098
3020 Plate 2 x 4 0 2092

3.1.4 Analiza zestawów

name img_url num_parts
World Map 11695
Eiffel Tower 10001
The Ultimate Battle for Chima 9987
Titanic 9092
Colosseum 9036
Millennium Falcon 7541
AT-AT 6785
The Razor Crest 6194
Lord of the Rings: Rivendell 6182
NINJAGO City Markets 6163

3.2 Analizy zapasów Rebrickable

3.2.1 Analiza kolorów

3.2.2 Analiza figurek

fig_num name img_url count
fig-001087 Woman, Blue Torso with White Arms, White Legs 101
fig-002330 Battle Droid, One Bent Arm, One Straight Arm 96
fig-002229 Skeleton, Standard Face, Ball Joint Arms (3626b Head) 59
fig-001127 Classic Spaceman, White with Airtanks (3842a Helmet) 51
fig-000020 Classic Spaceman, Red with Airtanks (3842a Helmet) 50
fig-003612 Battle Droid, Two Bent Arms 50
fig-007625 Pit Crew, Red Torso, Red Legs, Ferrari 34
fig-000285 Man, Blue Shirt, Blue Legs, Red Hard Hat 30
fig-006974 Martian 29
fig-000341 Classic Spaceman, Yellow with Airtanks (3842b Helmet) 27

3.2.3 Analiza części

part_num name img_url color_id count
2780 Technic Pin with Friction Ridges Lengthwise and Center Slots 0 68443
43093 Technic Axle Pin with Friction Ridges Lengthwise 1 21588
6558 Technic Pin Long with Friction Ridges Lengthwise, 2 Center Slots 1 20015
3023 Plate 1 x 2 0 16486
61332 Technic Pin with Friction Ridges Lengthwise with No Center Slots 0 16316
3024 Plate 1 x 1 15 15891
3004 Brick 1 x 2 15 15743
32062 Technic Axle 2 Notched 4 14078
3023 Plate 1 x 2 15 13605
3005 Brick 1 x 1 15 12458

3.2.4 Analiza zestawów

Z uwagi na to, że wiele zestawów z pierwszej 10 znajduje się w zapasach w podobnej liczbie, pokazany został tylko ten najliczniejszy.

set_num name img_url count
71025-0 Series 19 - Random Bag 110

3.3 Trendy na przestrzeni lat

Rok ograniczony został do 2022, z uwagi na to, że 2023 się jeszcze nie zakończył.

3.3.1 Wydane zestawy

3.3.2 Średnia wielkość zestawu

3.3.3 Ranking sumy wydanych motywów zestawów

Zbiór został uzupełniony o brakujace dane, tak żeby w każdym roku były wszystkie motywy.

3.4 Korelacja

year set_count max_parts mean_parts unique_themes
year 1.0000000 0.8843504 0.7867653 0.8047701 0.9403338
set_count 0.8843504 1.0000000 0.8772815 0.7072826 0.9578744
max_parts 0.7867653 0.8772815 1.0000000 0.7737871 0.8237919
mean_parts 0.8047701 0.7072826 0.7737871 1.0000000 0.7323595
unique_themes 0.9403338 0.9578744 0.8237919 0.7323595 1.0000000

4 Predykcja (forecast)

Próba przewidzenia cech z sekcji Korelacja w późniejszych latach. ## Model Arima

## 
## Prognoza dla set_count :
##      Point Forecast     Lo 80    Hi 80    Lo 95    Hi 95
## 2023       1076.140 1001.9394 1150.341 962.6599 1189.620
## 2024       1081.174  989.2417 1173.106 940.5758 1221.772
## 2025       1099.126  989.5507 1208.701 931.5451 1266.707
## 2026       1113.609  989.5417 1237.676 923.8646 1303.353
## 2027       1129.023  991.8242 1266.223 919.1953 1338.852
## 2028       1144.188  995.0487 1293.327 916.0992 1372.277
## 2029       1159.419  999.2177 1319.621 914.4120 1404.427
## 2030       1174.633 1004.0873 1345.179 913.8059 1435.460
## 2031       1189.851 1009.5536 1370.149 914.1097 1465.593
## 2032       1205.069 1015.5198 1394.617 915.1788 1494.958

## 
## Prognoza dla max_parts :
##      Point Forecast    Lo 80    Hi 80    Lo 95    Hi 95
## 2023       9400.870 7705.574 11096.17 6808.139 11993.60
## 2024       9537.496 7744.524 11330.47 6795.382 12279.61
## 2025       9674.122 7788.526 11559.72 6790.352 12557.89
## 2026       9810.748 7836.870 11784.63 6791.962 12829.53
## 2027       9947.373 7888.997 12005.75 6799.358 13095.39
## 2028      10083.999 7944.458 12223.54 6811.853 13356.15
## 2029      10220.625 8002.888 12438.36 6828.888 13612.36
## 2030      10357.251 8063.982 12650.52 6849.999 13864.50
## 2031      10493.877 8127.486 12860.27 6874.795 14112.96
## 2032      10630.503 8193.183 13067.82 6902.944 14358.06

## 
## Prognoza dla mean_parts :
##      Point Forecast    Lo 80    Hi 80    Lo 95    Hi 95
## 2023       236.9724 195.6295 278.3153 173.7439 300.2009
## 2024       240.1894 196.3290 284.0499 173.1107 307.2682
## 2025       243.4064 197.1653 289.6476 172.6867 314.1261
## 2026       246.6234 198.1183 295.1286 172.4412 320.8056
## 2027       249.8404 199.1724 300.5085 172.3503 327.3306
## 2028       253.0574 200.3151 305.7998 172.3949 333.7199
## 2029       256.2744 201.5363 311.0126 172.5597 339.9892
## 2030       259.4915 202.8278 316.1551 172.8319 346.1510
## 2031       262.7085 204.1826 321.2343 173.2009 352.2160
## 2032       265.9255 205.5949 326.2560 173.6578 358.1931

## 
## Prognoza dla unique_themes :
##      Point Forecast    Lo 80     Hi 80    Lo 95     Hi 95
## 2023       81.19442 75.54842  86.84041 72.55961  89.82922
## 2024       81.79806 74.75455  88.84156 71.02594  92.57017
## 2025       83.06011 74.66077  91.45945 70.21443  95.90579
## 2026       84.15483 74.63395  93.67572 69.59390  98.71577
## 2027       85.29208 74.75845  95.82571 69.18229 101.40188
## 2028       86.41852 74.96368  97.87337 68.89985 103.93720
## 2029       87.54771 75.23985  99.85557 68.72446 106.37096
## 2030       88.67620 75.57087 101.78154 68.63332 108.71908
## 2031       89.80487 75.94785 103.66189 68.61238 110.99736
## 2032       90.93349 76.36352 105.50346 68.65064 113.21634

## Model ETS

## 
## Prognoza dla set_count :
##      Point Forecast    Lo 80    Hi 80    Lo 95    Hi 95
## 2023       1085.048 1009.551 1160.545 969.5850 1200.511
## 2024       1111.350 1015.421 1207.280 964.6387 1258.062
## 2025       1137.652 1023.189 1252.116 962.5961 1312.709
## 2026       1163.955 1031.973 1295.936 962.1060 1365.803
## 2027       1190.257 1041.341 1339.172 962.5103 1418.003
## 2028       1216.559 1051.051 1382.067 963.4359 1469.682
## 2029       1242.861 1060.949 1424.774 964.6506 1521.072
## 2030       1269.164 1070.936 1467.391 966.0006 1572.327
## 2031       1295.466 1080.941 1509.990 967.3790 1623.553
## 2032       1321.768 1090.915 1552.621 968.7094 1674.827

## 
## Prognoza dla max_parts :
##      Point Forecast    Lo 80    Hi 80       Lo 95    Hi 95
## 2023       8498.832 3135.857 13861.81   296.86864 16700.80
## 2024       9199.610 3360.549 15038.67   269.53689 18129.68
## 2025       9900.388 3545.805 16254.97   181.89201 19618.88
## 2026      10601.166 3679.471 17522.86    15.34655 21186.99
## 2027      11301.944 3751.057 18852.83  -246.14111 22850.03
## 2028      12002.722 3751.605 20253.84  -616.27185 24621.72
## 2029      12703.500 3673.527 21733.47 -1106.65225 26513.65
## 2030      13404.277 3510.398 23298.16 -1727.10562 28535.66
## 2031      14105.055 3256.730 24953.38 -2486.02711 30696.14
## 2032      14805.833 2907.728 26703.94 -3390.74827 33002.41

## 
## Prognoza dla mean_parts :
##      Point Forecast    Lo 80    Hi 80    Lo 95    Hi 95
## 2023       237.9467 195.6046 280.2888 173.1901 302.7034
## 2024       237.9467 191.6096 284.2839 167.0802 308.8133
## 2025       237.9467 187.9326 287.9608 161.4568 314.4367
## 2026       237.9467 184.5081 291.3854 156.2194 319.6741
## 2027       237.9467 181.2902 294.6033 151.2980 324.5954
## 2028       237.9467 178.2455 297.6480 146.6415 329.2520
## 2029       237.9467 175.3487 300.5448 142.2112 333.6822
## 2030       237.9467 172.5801 303.3134 137.9771 337.9164
## 2031       237.9467 169.9241 305.9693 133.9151 341.9783
## 2032       237.9467 167.3680 308.5254 130.0059 345.8875

## 
## Prognoza dla unique_themes :
##      Point Forecast    Lo 80     Hi 80    Lo 95     Hi 95
## 2023       81.13525 75.40211  86.86839 72.36717  89.90333
## 2024       82.21588 74.93331  89.49844 71.07815  93.35360
## 2025       83.29650 74.74035  91.85265 70.21099  96.38201
## 2026       84.37712 74.71353  94.04071 69.59794  99.15631
## 2027       85.45775 74.80095  96.11454 69.15959 101.75591
## 2028       86.53837 74.97313  98.10361 68.85086 104.22588
## 2029       87.61899 75.21144 100.02655 68.64328 106.59471
## 2030       88.69962 75.50321 101.89602 68.51746 108.88178
## 2031       89.78024 75.83936 103.72112 68.45951 111.10097
## 2032       90.86086 76.21313 105.50860 68.45909 113.26264